package com.common.library.util;

import java.util.ArrayList;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;

public class HandlerUtil {
	
	
	/**
	 * 
	 * function: 
	 *
	 * @param handler
	 * 
	 * @ author: aXiBa 2012-2-15 下午04:30:51
	 */
	public static void sendMessage(Handler handler, int what) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	/**
	 * 
	 * function: 
	 *
	 * @param handler
	 * @param arg1
	 * 
	 * @ author: aXiBa 2012-2-15 下午04:30:51
	 */
	public static void sendMessage(Handler handler, int what, int arg1) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		msg.arg1 = arg1;
		
		// 发送消息
		handler.sendMessage(msg);
	}

	
	/**
	 * 
	 * function: sendMessage
	 *
	 * @param handler
	 * @param obj
	 * 
	 * @ author: aXiBa 2012-2-15 下午04:31:28
	 */
	public static void sendMessage(Handler handler, int what, Object obj) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		msg.obj = obj;
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	
	/**
	 * 
	 * function: sendMessage
	 *
	 * @param handler
	 * @param what
	 * @param arg1
	 * @param obj
	 * 
	 * @ author: aXiBa 2012-2-16 上午10:16:50
	 */
	public static void sendMessage(Handler handler, int what, int arg1, Object obj) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		msg.arg1 = arg1;
		msg.obj = obj;
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	
	/**
	 * 
	 * function: 
	 *
	 * @param handler
	 * @param what
	 * @param arg1
	 * @param arg2
	 * 
	 * @ author: aXiBa 2012-6-25 下午5:39:53
	 */
	public static void sendMessage(Handler handler, int what, int arg1, int arg2) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		msg.arg1 = arg1;
		msg.arg2 = arg2;
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	
	/**
	 * 
	 * function: 
	 *
	 * @param handler
	 * @param what
	 * @param arg1
	 * @param arg2
	 * @param obj
	 * 
	 * @ author: aXiBa 2012-6-25 下午5:44:48
	 */
	public static void sendMessage(Handler handler, int what, int arg1, int arg2, Object obj) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		msg.arg1 = arg1;
		msg.arg2 = arg2;
		msg.obj = obj;
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	
	/**
	 * 
	 * function: 
	 *
	 * @param handler
	 * @param what
	 * @param arg1
	 * @param obj
	 * @param str
	 * 
	 * @ author: aXiBa 2012-2-20 下午04:51:30
	 */
	public static void sendMessage(Handler handler, int what, int arg1, Object obj, String str) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		msg.arg1 = arg1;
		msg.obj = obj;

		Bundle bundle = new Bundle();
		bundle.putString("str", str);
		
		msg.setData(bundle);
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	
	/**
	 * 
	 * function: 
	 *
	 * @param handler
	 * @param what
	 * @param arg1
	 * @param obj
	 * @param str
	 * 
	 * @ author: aXiBa 2012-2-20 下午04:51:30
	 */
	public static void sendMessage(Handler handler, int what, String param1, String param2) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		
		Bundle bundle = new Bundle();
		bundle.putString("param1", param1);
		bundle.putString("param2", param2);
		
		msg.setData(bundle);
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	/**
	 * 
	 * function: 
	 *
	 * @param handler
	 * @param what
	 * @param param1
	 * @param param2
	 * @param param3
	 * @param param4
	 * 
	 * @ author: aXiBa 2012-12-20 上午10:52:11
	 */
	public static void sendMessage(Handler handler, int what, String param1, String param2, String param3, String param4) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		
		Bundle bundle = new Bundle();
		bundle.putString("param1", param1);
		bundle.putString("param2", param2);
		bundle.putString("param3", param3);
		bundle.putString("param4", param4);
		
		msg.setData(bundle);
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	/**
	 * 
	 * function:
	 * 
	 * @param handler
	 * @param what
	 * @param arg1
	 * @param param1
	 * @param param2
	 * @param param3
	 * 
	 */
	public static void sendMessage(Handler handler, int what, int arg1, String param1, String param2, String param3) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		msg.arg1 = arg1;
		
		Bundle bundle = new Bundle();
		bundle.putString("param1", param1);
		bundle.putString("param2", param2);
		bundle.putString("param3", param3);
		
		msg.setData(bundle);
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	/**
	 * function：
	 * 
	 * @param handler
	 * @param what
	 * @param arg1
	 * @param param1
	 * @param param2
	 * @param param3 
	 * @param param4
	 * 
	 * @author LiPeng 2014-2-11 14:31
	 */
	public static void sendMessage(Handler handler, int what, int arg1, String param1, String param2, String param3, String param4) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		
		Bundle bundle = new Bundle();
		bundle.putString("param1", param1);
		bundle.putString("param2", param2);
		bundle.putString("param3", param3);
		bundle.putString("param4", param4);
		
		msg.setData(bundle);
		
		// 发送消息
		handler.sendMessage(msg);
	}
	
	
	
	/**
	 * 
	 * function: sendMessage
	 *
	 * @param handler
	 * @param what
	 * @param list
	 * 
	 * @ author: aXiBa 2012-2-15 下午05:53:13
	 */
	public static void sendMessage(Handler handler, int what, ArrayList<Parcelable> list) {
		
		Message msg = handler.obtainMessage();
		
		msg.what = what;
		
		Bundle bundle = new Bundle();
		bundle.putParcelableArrayList("list", list);
		
		msg.setData(bundle);
		
		// 发送消息
		handler.sendMessage(msg);
	}
}
